﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace Foursquare
{
    public partial class ItemDetailPage : PhoneApplicationPage
    {
        public ItemDetailPage()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(ItemDetailPage_Loaded);
        }

        void ItemDetailPage_Loaded(object sender, RoutedEventArgs e)
        {
            FoursquareClient client = new FoursquareClient();
            client.GetVenuePhotosCompleted +=
                new FoursquareClient.GetVenuesPhotosCompletedEventHandler(client_GetVenuePhotosCompleted);
            client.GetVenuePhotoAsync((App.Current as App).venueItem.id, 15, 15);
        }

        void client_GetVenuePhotosCompleted(object sender, List<PhotoItem> venues)
        {
            var photos = from item in venues select item.url;
            //photosListBox.ItemsSource = photos;
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if ((App.Current as App).venueItem != null)
            {
                this.DataContext = (App.Current as App).venueItem;
            }
            base.OnNavigatedTo(e);
        }
    }
}